package de.breitbeil.jbooking.ui.form;

import javax.swing.JComponent;
import javax.swing.JLabel;

import org.springframework.richclient.filechooser.DefaultFileFilter;
import org.springframework.richclient.form.AbstractForm;
import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
import org.springframework.richclient.form.builder.TableFormBuilder;

import de.breitbeil.jbooking.richclient.filechooser.FileChooserComboBox;

public class ExportForm extends AbstractForm {

    public static final String ID = "exportForm";
    
    public ExportForm(ExportFormObject formObject) {
        super(formObject);
        setId(ID);
    }

    @Override
    protected JComponent createFormControl() {
        SwingBindingFactory bindingFactory = (SwingBindingFactory) getBindingFactory();
        TableFormBuilder formBuilder = new TableFormBuilder(bindingFactory);
        formBuilder.setLabelAttributes("colGrId=label colSpec=right:pref");
        
        FileChooserComboBox fileChooser = new FileChooserComboBox(getFormModel(), "output");
        fileChooser.setFilter(new DefaultFileFilter("zip"));

        formBuilder.addSeparator(getMessage(ID+".fileSeparator.label"));
        formBuilder.row();
        formBuilder.getLayoutBuilder().cell( new JLabel("Datei"), formBuilder.getLabelAttributes() );
        formBuilder.getLayoutBuilder().gapCol();        
        formBuilder.getLayoutBuilder().cell( fileChooser.getControl() );
        formBuilder.row();
        
        return formBuilder.getForm();
    }
    

}
